<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:include href="core\form.xsl"/>
	<xsl:include href="core\level0.xsl"/>
	
<xsl:template match="page">
	<xsl:call-template name="page_content"/>
</xsl:template>

<xsl:template name="page_content">
<!-- <table border="0" cellspacing="0" cellpadding="4" width="100%">
	<tr><td align="center">
<a href="premium_finance_companies.asp" class="linkbold"><font color="{$color_main_first1}">Premium Companies List</font></a> &#160;|&#160; <a href="premium_finance_companies.asp?fc=all" class="linkbold"><font color="{$color_main_first1}">All Finance Companies</font></a> &#160;|&#160; <a href="insurance_companies_search.asp" class="linkbold"><font color="{$color_main_first1}">Insurance Company Search</font></a> 
	</td></tr>
</table> -->
<xsl:choose>
	<xsl:when test="fc='all'"><table cellspacing="0" cellpadding="4" width="100%">
	<tr><td align="center">
<a href="premium_finance_companies.asp" class="linkbold" title="Premium Finance Companies List"><font color="{$color_main_first1}">Premium Finance Companies List</font></a> &#160;|&#160; <font color="#666666"><b>All Finance Companies</b></font>  &#160;|&#160; <a href="finance_companies_search.asp" class="linkbold"><font color="{$color_main_first1}">Finance Company Search</font></a> 
	</td></tr>
</table></xsl:when>
	<xsl:otherwise><table cellspacing="0" cellpadding="4" width="100%">
	<tr><td align="center">
<font color="#666666"><b>Premium Finance Companies List</b></font> &#160;|&#160; <a href="main.asp?-finance_companies_search.asp-=&amp;finance_companies_list_frm_auto=1&amp;company_name=&amp;states_id=61&amp;countries_id=&amp;submit.x=80&amp;submit.y=7" class="linkbold" title="All Finance Companies"><font color="{$color_main_first1}">All Finance Companies</font></a>  &#160;|&#160; <a href="finance_companies_search.asp" class="linkbold" title="Finance Company Search"><font color="{$color_main_first1}">Finance Company Search</font></a> 
	</td></tr>
</table></xsl:otherwise>
</xsl:choose>
<xsl:call-template name="title_page">
		<xsl:with-param name="titleText">
			<xsl:choose>
					<xsl:when test="fc='all'">All Finance Companies List</xsl:when>
			  		<xsl:otherwise>Premium Finance Services</xsl:otherwise>
					</xsl:choose>
		</xsl:with-param>
	</xsl:call-template>
  <table align="center" cellpadding="0" cellspacing="0" width="100%">
	<xsl:choose>
	  <xsl:when test="fc='all'">
		<table cellspacing="2" cellpadding="0" align="center">
			<tr bgcolor="{$header_bg_color}">
		 		<td  class="listtitle">&#160;Company Name <img src="{$img_path_templates}/spacer.gif" alt="" align="absmiddle" width="2" height="30" border="0"/></td>
				<td  class="listtitle">&#160;Address</td>
				<td  class="listtitle">&#160;Contact Information</td>
			</tr>
			<xsl:for-each select="finance_companies/row">
				<xsl:variable name="url"><xsl:value-of select="url"/></xsl:variable>
				<xsl:variable name="email"><xsl:value-of select="url"/></xsl:variable>
				<xsl:variable name="fc_id"><xsl:value-of select="id"/></xsl:variable>
			 	<xsl:variable name="src">
					<xsl:value-of select="$media_path"/>
					<xsl:value-of select="logo"/>
		  		</xsl:variable>
 				<tr>
 					<!-- <xsl:if test="position() mod 2 = 0">
						<xsl:attribute name="bgcolor"><xsl:value-of select="$bgcolor_light"/></xsl:attribute>
					</xsl:if> -->
					
						<xsl:choose>
							<xsl:when test="string-length(logo)>4">
							<td valign="top" align="center">
							<img src="{$img_path_templates}/spacer.gif" alt="" width="150" height="6" border="0"/>
								<div align="left" style="padding-left : 15px;"><b><xsl:value-of select="name" disable-output-escaping="yes"/>&#160;&#160;&#160;&#160;</b></div><img border="0" vspace="2" hspace="4" align="middle">
									<xsl:attribute name="src"><xsl:value-of select="$src" disable-output-escaping="yes"/></xsl:attribute>
									<xsl:attribute name="alt"><xsl:value-of select="name" disable-output-escaping="yes"/></xsl:attribute>
								</img>
							</td>
							</xsl:when>
							<xsl:otherwise>
							<td valign="top">
							<img src="{$img_path_templates}/spacer.gif" alt="" width="150" height="6" border="0"/><div align="left" style="padding-left : 15px;"><b><xsl:value-of select="col[@name='name']" disable-output-escaping="yes"/>&#160;&#160;&#160;&#160;</b></div>
							<img src="{$img_path_templates}/spacer.gif" alt="" width="150" height="4" border="0"/>
							</td>
							</xsl:otherwise>
						</xsl:choose>
					
					<td  bgcolor="{$color_right_info}">
					<div align="left" style="padding-left : 10px;">
						<xsl:if test="string-length(address_1)>0"><xsl:value-of select="address_1"/>&#160;&#160;&#160;&#160;<br/></xsl:if>
						<xsl:if test="string-length(address_2)>0"><xsl:value-of select="address_2"/><br/></xsl:if>
						<xsl:if test="string-length(address_3)>0"><xsl:value-of select="address_3"/><br/></xsl:if>
						<xsl:if test="string-length(city)>0"><xsl:value-of select="city"/>, </xsl:if> 
						<xsl:if test="string-length(state)>0 and not(state='--Not specified--')"><xsl:value-of select="state"/></xsl:if>
						<xsl:if test="string-length(zipcode)>0"><xsl:value-of select="zipcode"/></xsl:if><br/>
						<xsl:value-of select="country"/>
					</div>	
					</td>
					<td valign="top">
						<table cellspacing="0" cellpadding="0">
						<xsl:if test="string-length(phone)>0">
						<tr>
							<td>&#160;&#160;</td>
							<td><img src="{$img_path_templates}/{$header_bg_color}/buttons/phone.gif" border="0" hspace="2" vspace="2"/></td>
							<td>&#160;Phone:&#160;&#160;<xsl:value-of select="phone"/></td>
						</tr>
						</xsl:if>
						<xsl:if test="string-length(fax)>0">
						<tr>
							<td>&#160;&#160;</td>
							<td></td>
							<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;Fax:&#160;
								<xsl:value-of select="fax"/>		</td>
						</tr>		
						</xsl:if>
						<xsl:if test="string-length(email)>0">
							<tr>
								<td>&#160;&#160;</td>
								<td><a href="mailto:{$email}"><img src="{$img_path_templates}/{$header_bg_color}/buttons/contact_to_broker.gif" border="0" hspace="2" vspace="2" valign="bottom"/></a></td>
								<td>&#160;<a href="mailto:{$email}"><font color="{$color_main_first1}"><xsl:value-of select="email"/></font></a></td>
							</tr>
						</xsl:if>
						<xsl:if test="string-length(url)>0">
						<tr>
							<td>&#160;&#160;</td>
							<td><a target="_blank"><xsl:attribute name="href"><xsl:call-template name="make_url"><xsl:with-param name="url" select="$url"/></xsl:call-template></xsl:attribute><img src="{$img_path_templates}/{$header_bg_color}/buttons/site.gif" border="0" vspace="2" hspace="2" valign="bottom"/></a></td>
							<td>&#160;<a target="_blank"><xsl:attribute name="href"><xsl:call-template name="make_url"><xsl:with-param name="url" select="$url"/></xsl:call-template></xsl:attribute><font color="{$color_main_first1}"><xsl:value-of  select="$url"/></font></a></td>
						</tr>
						</xsl:if>
						<xsl:if test="number_of_contacts>0">
						<tr>
							<td>&#160;&#160;</td>
							<td><a href="#" title="Contacts View">
							<xsl:attribute name="onClick">
								window.open('contacts_view.asp?companies_id=<xsl:value-of select="$fc_id"/>&amp;company=fin',null,'height=250,width=300,resizable=yes,scrollbars=yes')
							</xsl:attribute>
							<img src="{$img_path_templates}/{$header_bg_color}/buttons/info.gif" border="0" vspace="2" hspace="2" valign="bottom"/></a></td>
							<td>&#160;<a href="#" title="Contacts View">
							<xsl:attribute name="onClick">
								window.open('contacts_view.asp?companies_id=<xsl:value-of select="$fc_id"/>&amp;company=fin',null,'height=250,width=300,resizable=yes,scrollbars=yes')
							</xsl:attribute><font color="{$color_main_first1}">View Company Contacts</font>
							</a></td>
							</tr>
						</xsl:if>
						
 						<xsl:if test="descr_len>0">
							<br/><br/>
							<a href="finance_company_details.asp??companies_id={$fc_id}">
								View Company Info
							</a>
						</xsl:if> 
						</table>
					</td>
				</tr>
				<tr><td colspan="3" bgcolor="#e0e0e0"><img src="{$img_path_templates}/spacer.gif" alt="" width="150" height="1" border="0"/></td></tr>
			</xsl:for-each>
		</table>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:for-each select="finance_companies/row">
	 	  <xsl:variable name="src">
			<xsl:value-of select="$media_path"/>
			<xsl:value-of select="logo"/>
		  </xsl:variable>
	      <tr><td valign="top">
		    <xsl:choose>
			  <xsl:when test="position() mod 2 = 0">
			    <table width="100%" cellpadding="5" cellspacing="2" align="center">
				 <tr>
		        	<td valign="top" colspan="2"><hr width="100%" size="1" noshade="true"  color="{$header_bg_color}"/></td>
				</tr>
			      <tr>
		            <td valign="middle" width="460">
			          <xsl:value-of select="note" disable-output-escaping="yes"/>
		            </td>
		            <td valign="top" align="center">
		              <xsl:if test="string-length(logo)>4">
			            <xsl:choose>
			              <xsl:when test="contains($src,'jpg') or contains($src,'JPG')  or contains($src,'jpeg') or contains($src,'JPEG')">
							<xsl:choose>
							<xsl:when test="id=0">
 				            <a href="{url}" target="blank">
				              <img border="0" vspace="2" hspace="4">
				                <xsl:attribute name="src"><xsl:value-of select="$src" disable-output-escaping="yes"/></xsl:attribute>
				                <xsl:attribute name="alt"><xsl:value-of select="alt" disable-output-escaping="yes"/></xsl:attribute>
				              </img>
			                </a>
							</xsl:when>
							<xsl:otherwise>
 				            <a href="finance_company_details.asp?companies_id={id}">
				              <img border="0" vspace="2" hspace="4">
				                <xsl:attribute name="src"><xsl:value-of select="$src" disable-output-escaping="yes"/></xsl:attribute>
				                <xsl:attribute name="alt"><xsl:value-of select="name" disable-output-escaping="yes"/></xsl:attribute>
				              </img>
			                </a>
							</xsl:otherwise>
			            	</xsl:choose>							
			              </xsl:when>
			              <xsl:otherwise><!-- No Image --></xsl:otherwise>
			            </xsl:choose>
		              </xsl:if>
		              <br/>
		            </td>
			      </tr> 
				   <xsl:if test="position() != last()">
				  <tr>
		        	<td valign="top" colspan="2"><hr width="100%" size="1" noshade="true"  color="{$header_bg_color}"/></td>
				</tr></xsl:if>
			    </table>
		      </xsl:when>
			  <xsl:otherwise>
			    <table width="100%" cellpadding="5" cellspacing="2">
				
			      <tr>
		            <td valign="top" align="center">
		              <xsl:if test="string-length(logo)>4">
			            <xsl:choose>
			              <xsl:when test="contains($src,'jpg') or contains($src,'JPG')  or contains($src,'jpeg') or contains($src,'JPEG')">
							<xsl:choose>
							<xsl:when test="id=0">
							<a href="{url}" target="blank">
				              <img border="0" vspace="2" hspace="4">
				                <xsl:attribute name="src"><xsl:value-of select="$src" disable-output-escaping="yes"/></xsl:attribute>
				                <xsl:attribute name="alt"><xsl:value-of select="alt" disable-output-escaping="yes"/></xsl:attribute>
				              </img>
			                </a>
							</xsl:when>
							<xsl:otherwise>
							<a href="finance_company_details.asp?companies_id={id}">
				              <img border="0" vspace="2" hspace="4">
				                <xsl:attribute name="src"><xsl:value-of select="$src" disable-output-escaping="yes"/></xsl:attribute>
				                <xsl:attribute name="alt"><xsl:value-of select="name" disable-output-escaping="yes"/></xsl:attribute>
				              </img>
			                </a>							
							</xsl:otherwise>
							</xsl:choose>
			              </xsl:when>
			              <xsl:otherwise><!-- No Image --></xsl:otherwise>
			            </xsl:choose>
		              </xsl:if>
		              <br/>
		            </td>
		              <td valign="middle" width="460"><xsl:value-of select="note" disable-output-escaping="yes"/></td>
			      </tr>
			    </table>
			  </xsl:otherwise>
			</xsl:choose>
		  </td></tr>
	    </xsl:for-each>
	  </xsl:otherwise>
	</xsl:choose>
  </table>
</xsl:template>

<xsl:template match="row/logo" mode="multiColumn">
	<xsl:param name="nodes" select="/.."/>
  	<xsl:param name="numCols" select="1"/>
  	<xsl:variable name="vCurPosition" select="position()"/>
  	<xsl:choose>
    <xsl:when test="$vCurPosition mod (2 * $numCols) = 1">
    	<tr bgcolor="{$bgcolor_light}">
        	<xsl:apply-templates mode="normal" select="$nodes[position() >= $vCurPosition and position() &lt; $vCurPosition + $numCols]"/>
		</tr>
	</xsl:when>
    <xsl:when test="$vCurPosition mod $numCols = 1">
		<tr>
        	<xsl:apply-templates mode="normal" select="$nodes[position() >= $vCurPosition and position() &lt; $vCurPosition + $numCols]"/>
		</tr>
	</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="row/name" mode="normal">
	<xsl:if test="string-length(../logo)>4">
	    <xsl:choose>
	    <xsl:when test="contains(../logo,'jpg') or contains(../logo,'JPG') or contains(../logo,'jpeg') or contains(../logo,'JPEG')">
		    <a href="finance_company_group.asp?c={../id}">
				<img border="0" vspace="2" hspace="4">
			    	<xsl:attribute name="src">
	              		<xsl:value-of select="$media_path"/>
						<xsl:value-of select="../logo"/>
	            	</xsl:attribute>
			    	<xsl:attribute name="alt"><xsl:value-of select="." disable-output-escaping="yes"/></xsl:attribute>
			  	</img>
		    </a>
		</xsl:when>
		<xsl:otherwise>No Image</xsl:otherwise>
	    </xsl:choose>
  	</xsl:if>
  	<br/>
  	<a href="finance_company_group.asp?c={../id}"><xsl:value-of select="." disable-output-escaping="yes"/></a>
</xsl:template>

<xsl:template match="row/logo" mode="normal">
	<td>
		<xsl:choose>
		<xsl:when test="contains(../logo,'jpg') or contains(../logo,'JPG') or contains(../logo,'jpeg') or contains(../logo,'JPEG')">
			<a href="finance_company_group.asp?fc_id={../id}">
				<img border="0" vspace="2" hspace="4">
					<xsl:attribute name="src">
						<xsl:value-of select="$media_path"/>
						<xsl:value-of select="../logo"/>
					</xsl:attribute>
					<xsl:attribute name="alt"><xsl:value-of select="." disable-output-escaping="yes"/></xsl:attribute>
			  	</img>
			</a>
		</xsl:when>
		<xsl:otherwise>No Image</xsl:otherwise>
		</xsl:choose>
		<br/>
		<a href="finance_company_group.asp?fc_id={../id}"><xsl:value-of select="../name" disable-output-escaping="yes"/></a><br/>
		<xsl:if test="string-length(../curr_rate)>0">Curr rate: <xsl:value-of select="../curr_rate"/></xsl:if>
	</td>
</xsl:template>

</xsl:stylesheet>
